<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue-2.6.12.js"></script>
  <style type="text/css">
    .red_bg{
        background-color: red;
    }
    .green_bg{
        background-color: green;
    }
</style>
</head>
<body>
  <div id="app">
    <div :class="{red_bg:showred,grren_bg:!showred}">点击按钮改变背景样式:{{class_name}}</div>
    <button @click="showred=!showred">点我</button>
  </div>
  <script type="text/javascript">
    const vm = new Vue({
      el:"#app",
      data:{
        showred:true
      }
    });
  </script>
</body>
</html>